package com.ruoyi.vehicle.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.vehicle.domain.StationInfo;
import com.ruoyi.vehicle.service.IStationInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 站点信息Controller
 * 
 * @author yyj
 * @date 2025-08-16
 */
@RestController
@RequestMapping("/infos")
public class StationInfoController extends BaseController
{
    @Autowired
    private IStationInfoService stationInfoService;

    /**
     * 查询站点信息列表
     */
    @RequiresPermissions("vehicle:infos:list")
    @GetMapping("/list")
    public TableDataInfo list(StationInfo stationInfo)
    {
        startPage();
        List<StationInfo> list = stationInfoService.selectStationInfoList(stationInfo);
        return getDataTable(list);
    }

    /**
     * 导出站点信息列表
     */
    @RequiresPermissions("vehicle:infos:export")
    @Log(title = "站点信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StationInfo stationInfo)
    {
        List<StationInfo> list = stationInfoService.selectStationInfoList(stationInfo);
        ExcelUtil<StationInfo> util = new ExcelUtil<StationInfo>(StationInfo.class);
        util.exportExcel(response, list, "站点信息数据");
    }

    /**
     * 获取站点信息详细信息
     */
    @RequiresPermissions("vehicle:infos:query")
    @GetMapping(value = "/{stationId}")
    public AjaxResult getInfo(@PathVariable("stationId") Long stationId)
    {
        return success(stationInfoService.selectStationInfoByStationId(stationId));
    }

    /**
     * 新增站点信息
     */
    @RequiresPermissions("vehicle:infos:add")
    @Log(title = "站点信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StationInfo stationInfo)
    {
        return toAjax(stationInfoService.insertStationInfo(stationInfo));
    }

    /**
     * 修改站点信息
     */
    @RequiresPermissions("vehicle:infos:edit")
    @Log(title = "站点信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StationInfo stationInfo)
    {
        return toAjax(stationInfoService.updateStationInfo(stationInfo));
    }

    /**
     * 删除站点信息
     */
    @RequiresPermissions("vehicle:infos:remove")
    @Log(title = "站点信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{stationIds}")
    public AjaxResult remove(@PathVariable Long[] stationIds)
    {
        return toAjax(stationInfoService.deleteStationInfoByStationIds(stationIds));
    }
}
